package com.znz.analysis.mongo;

import org.bson.Document;

import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;

@Deprecated
public class MongoDBJDBC {

	public MongoCollection<Document> getCollection(MongoDatabase mongoDatabase, String collectionName) {
		// Use Collection
		MongoCollection<Document> coll = mongoDatabase.getCollection(collectionName);
		return coll;
	}

	public void insert(MongoCollection<Document> coll, Document document) {
		coll.insertOne(document);
	}

	public static void main(String args[]) {
		try {
			MongoDBJDBC jdbc = new MongoDBJDBC();
			MongoDatabase mongoDatabase = MongoConnector.getInstance().getMongoDatabase();
			MongoCollection<Document> collection = jdbc.getCollection(mongoDatabase, "test-ii");
			Document document = new Document("test111", "sdsds");
			jdbc.insert(collection, document);
		} catch (Exception e) {
			System.err.println(e.getClass().getName() + ": " + e.getMessage());
		}
	}
}
